package com.wash.shoes.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.wash.shoes.entity.AccessoriesPo;
import com.wash.shoes.entity.QualityInspectionPo;
import com.wash.shoes.mapper.AccessoriesMapper;
import com.wash.shoes.service.IAccessoriesService;
import com.wash.shoes.service.IQualityInspectionService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 物品配饰服务类
 */
@Service
@RequiredArgsConstructor
public class AccessoriesServiceImpl extends ServiceImpl<AccessoriesMapper, AccessoriesPo> implements IAccessoriesService {

    private final IQualityInspectionService qualityInspectionService;
    @Override
    @Transactional
    public boolean save(AccessoriesPo entity) {
        super.save(entity);
        QualityInspectionPo qualityInspectionPo =  new QualityInspectionPo();
        qualityInspectionPo.setType(entity.getType());
        qualityInspectionPo.setWashCode(entity.getWashCode());
        qualityInspectionPo.setOrderId(entity.getOrderId());
        qualityInspectionPo.setStatus("0");//插入一条未质检的记录
        qualityInspectionPo.setExtendInfo(entity.getExtendInfo());
        qualityInspectionPo.setRemark(entity.getRemark());
        qualityInspectionPo.setId(IdUtils.fastSimpleUUID());
        return qualityInspectionService.save(qualityInspectionPo);
    }
}
